﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;

namespace PathTracing
{
    static class TracingDataCollector
    {
        public static List<Plane> GetAllPlanes()
        {
            List<Plane> planes = new List<Plane>();

            //Plane test_plane;
            //test_plane.BaseColor = new Vector3(1, 1, 1);
            //test_plane.Origin = Vector3.zero;
            //test_plane.Normal = Vector3.up;
            //test_plane.ReflectFactor = 0;
            //test_plane.EmmisionColor = new Vector3(0.1f,0.1f, 0.1f);
            //test_plane.Roughess = 1;
            //planes.Add(test_plane);

            foreach(PlaneProxy proxy in UnityEngine.Object.FindObjectsOfType<PlaneProxy>())
            {
                planes.Add(proxy.GetPlane());
            }

            return planes;
        }

        public static List<Sphere> GetAllSpheres()
        {
            List<Sphere> spheres = new List<Sphere>();

            //Sphere test_sphere;
            //test_sphere.BaseColor = new Vector3(1, 1, 1);
            //test_sphere.Origin = Vector3.zero;
            //test_sphere.Radius = 1;
            //test_sphere.ReflectFactor = 0;
            //test_sphere.EmmisionColor = new Vector3(1, 1, 1);
            //test_sphere.Roughess = 1;
            //spheres.Add(test_sphere);

            foreach (SphereProxy proxy in UnityEngine.Object.FindObjectsOfType<SphereProxy>())
            {
                spheres.Add(proxy.GetSphere());
            }

            return spheres;
        }

        public static List<DirectionLight> GetAllDirectionLights()
        {
            List<DirectionLight> lights = new List<DirectionLight>();

            //DirectionLight test_light;
            //test_light.LightColor = new Vector3(1, 1, 1);
            //test_light.LightDirection = new Vector3(-1, -1, 0).normalized;
            //lights.Add(test_light);

            foreach (DirectionLightProxy proxy in UnityEngine.Object.FindObjectsOfType<DirectionLightProxy>())
            {
                lights.Add(proxy.GetDirectionLight());
            }

            return lights;
        }

        public static List<Triangle> GetAllTriangles()
        {
            List<Triangle> triangles = new List<Triangle>();

            foreach (TriangleProxy proxy in UnityEngine.Object.FindObjectsOfType<TriangleProxy>())
            {
                triangles.AddRange(proxy.GetAllTriangles());
            }

            return triangles;
        }
    }
}
